package com.lonely.api.shein.service;

import com.lonely.api.shein.exception.OpenSdkException;
import com.lonely.api.shein.http.RequestBuilder;
import com.lonely.api.shein.model.AuthInfo;

/**
 * shein sdk客户端接口
 *
 * @author fzzf
 */
public interface SheinOpenSDKClient {

    /**
     * 根据临时token获取 openKeyId和secretKey
     * 接口地址：https://open.sheincorp.com/documents/apidoc/detail/3001146
     *
     * @param tempToken tempToken
     * @return token object
     * @throws OpenSdkException If a request fails， throw an exception
     */
    String getToken(String tempToken, AuthInfo authInfo) throws OpenSdkException;

    /**
     * 发送http get请求
     *
     * @param requestBuilder Request Builder
     * @return response string
     * @throws OpenSdkException If a request fails， throw an exception
     */
    String get(RequestBuilder requestBuilder) throws OpenSdkException;

    /**
     * 发送http post请求
     *
     * @param requestBuilder Request Builder
     * @return response string
     * @throws OpenSdkException If a request fails， throw an exception
     */
    String post(RequestBuilder requestBuilder) throws OpenSdkException;

    /**
     * 临时token调用返回的SecretKey 需要解密
     * The secretKey obtained via the get-by-token interface is encrypted and needs to be decrypted before use.
     *
     * @param encryptedData 待解密的数据
     * @return SecretKey 应用的SecretKey
     */
    String decryptSecretKey(String encryptedData, String secretKey);

    /**
     * 解密事件数据
     * webhook回调中的数据是加密的，需要解密才能使用。
     *
     * @param encryptedData encrypted data
     * @return EventData
     */
    String decryptEventData(String encryptedData, String secretKey);
}
